Micron Document
<!DOCTYPE html>
<html class="client-nojs vector-feature-night-mode-disabled vector-feature-language-in-header-enabled vector-feature-language-in-main-page-header-disabled vector-feature-page-tools-pinned-disabled vector-feature-toc-pinned-clientpref-1 vector-feature-main-menu-pinned-disabled vector-feature-limited-width-clientpref-1 vector-feature-limited-width-content-enabled vector-feature-custom-font-size-clientpref-1 vector-feature-appearance-pinned-clientpref-1 vector-sticky-header-enabled" lang="en" dir="ltr"><head>
<meta charset="UTF-8">
<title>Program optimization</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="canonical" href="https://en.wikipedia.org/wiki/Program_optimization"> <link href="./mw/ext.cite.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/ext.pygments.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.icons.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.search.codex.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/user.styles.css" rel="stylesheet" type="text/css">
<meta name="ResourceLoaderDynamicStyles" content="">
<link rel="stylesheet" type="text/css" href="./mw/site.styles.css">
<link rel="stylesheet" type="text/css" href="./mw/noscript.css">
<link rel="stylesheet" type="text/css" href="./footer.css">
<link rel="stylesheet" type="text/css" href="./vector-2022.css">
</head>
<body class="skin--responsive skin-vector skin-vector-search-vue mediawiki ltr sitedir-ltr mw-hide-empty-elt ns-0 ns-subject page-Program_optimization rootpage-Program_optimization skin-vector-2022 action-view">
<div class="mw-page-container">
<div class="mw-page-container-inner">
<div class="mw-content-container">
<main id="content" class="mw-body">
<header class="mw-body-header vector-page-titlebar">
<h1 id="firstHeading" class="firstHeading mw-first-heading">
<span id="openzim-page-title" class="mw-page-title-main"><span class="mw-page-title-main">Program optimization</span></span>
</h1>
</header>
<a id="top"></a>
<div id="bodyContent" class="vector-body ve-init-mw-desktopArticleTarget-targetContainer" aria-labelledby="firstHeading" data-mw-ve-target-container="">
<div id="mw-content-text" class="mw-body-content mw-content-ltr" lang="en" dir="ltr"><div class="mw-content-ltr mw-parser-output" lang="en" dir="ltr">
<style data-mw-deduplicate="TemplateStyles:r1251242444">
/* start https://en.wikipedia.org/ */


.mw-parser-output .ambox{border:1px solid #a2a9b1;border-left:10px solid #36c;background-color:#fbfbfb;box-sizing:border-box}.mw-parser-output .ambox+link+.ambox,.mw-parser-output .ambox+link+style+.ambox,.mw-parser-output .ambox+link+link+.ambox,.mw-parser-output .ambox+.mw-empty-elt+link+.ambox,.mw-parser-output .ambox+.mw-empty-elt+link+style+.ambox,.mw-parser-output .ambox+.mw-empty-elt+link+link+.ambox{margin-top:-1px}html body.mediawiki .mw-parser-output .ambox.mbox-small-left{margin:4px 1em 4px 0;overflow:hidden;width:238px;border-collapse:collapse;font-size:88%;line-height:1.25em}.mw-parser-output .ambox-speedy{border-left:10px solid #b32424;background-color:#fee7e6}.mw-parser-output .ambox-delete{border-left:10px solid #b32424}.mw-parser-output .ambox-content{border-left:10px solid #f28500}.mw-parser-output .ambox-style{border-left:10px solid #fc3}.mw-parser-output .ambox-move{border-left:10px solid #9932cc}.mw-parser-output .ambox-protection{border-left:10px solid #a2a9b1}.mw-parser-output .ambox .mbox-text{border:none;padding:0.25em 0.5em;width:100%}.mw-parser-output .ambox .mbox-image{border:none;padding:2px 0 2px 0.5em;text-align:center}.mw-parser-output .ambox .mbox-imageright{border:none;padding:2px 0.5em 2px 0;text-align:center}.mw-parser-output .ambox .mbox-empty-cell{border:none;padding:0;width:1px}.mw-parser-output .ambox .mbox-image-div{width:52px}@media(min-width:720px){.mw-parser-output .ambox{margin:0 10%}}@media print{body.ns-0 .mw-parser-output .ambox{display:none!important}}


/* end https://en.wikipedia.org/ */
</style><style data-mw-deduplicate="TemplateStyles:r1248332772">
/* start https://en.wikipedia.org/ */


.mw-parser-output .multiple-issues-text{width:95%;margin:0.2em 0}.mw-parser-output .multiple-issues-text>.mw-collapsible-content{margin-top:0.3em}.mw-parser-output .compact-ambox .ambox{border:none;border-collapse:collapse;background-color:transparent;margin:0 0 0 1.6em!important;padding:0!important;width:auto;display:block}body.mediawiki .mw-parser-output .compact-ambox .ambox.mbox-small-left{font-size:100%;width:auto;margin:0}.mw-parser-output .compact-ambox .ambox .mbox-text{padding:0!important;margin:0!important}.mw-parser-output .compact-ambox .ambox .mbox-text-span{display:list-item;line-height:1.5em;list-style-type:disc}body.skin-minerva .mw-parser-output .multiple-issues-text>.mw-collapsible-toggle,.mw-parser-output .compact-ambox .ambox .mbox-image,.mw-parser-output .compact-ambox .ambox .mbox-imageright,.mw-parser-output .compact-ambox .ambox .mbox-empty-cell,.mw-parser-output .compact-ambox .hide-when-compact{display:none}


/* end https://en.wikipedia.org/ */
</style>
<p>In <a href="Computer_science" title="Computer science">computer science</a>, <b>program optimization</b>, <b>code optimization</b>, or <b>software optimization</b> is the process of modifying a software system to make some aspect of it work more <a href="Algorithmic_efficiency" title="Algorithmic efficiency">efficiently</a> or use fewer resources.<sup id="cite_ref-1" class="reference"><a href="#cite_note-1"><span class="cite-bracket">[</span>1<span class="cite-bracket">]</span></a></sup> In general, a <a href="Computer_program" title="Computer program">computer program</a> may be optimized so that it executes more rapidly, or to make it capable of operating with less <a href="Computer_data_storage" title="Computer data storage">memory storage</a> or other resources, or draw less power.
</p>
<meta property="mw:PageProp/toc">
<div class="mw-heading mw-heading2"><h2 id="Overview">Overview</h2></div>
<p>Although the term "optimization" is derived from "optimum",<sup id="cite_ref-2" class="reference"><a href="#cite_note-2"><span class="cite-bracket">[</span>2<span class="cite-bracket">]</span></a></sup> achieving a truly optimal system is rare in practice, which is referred to as <a href="Superoptimization" title="Superoptimization">superoptimization</a>. Optimization typically focuses on improving a system with respect to a specific quality metric rather than making it universally optimal. This often leads to trade-offs, where enhancing one metric may come at the expense of another. One popular example is <a href="Space-time_tradeoff" class="mw-redirect" title="Space-time tradeoff">space-time tradeoff</a>, reducing a program’s execution time by increasing its memory consumption. Conversely, in scenarios where memory is limited, engineers might prioritize a slower <a href="Algorithm" title="Algorithm">algorithm</a> to conserve space. There is rarely a single design that can excel in all situations, requiring <a href="Engineers" class="mw-redirect" title="Engineers">engineers</a> to prioritize attributes most relevant to the application at hand.
</p><p>Furthermore, achieving absolute optimization often demands disproportionate effort relative to the benefits gained. Consequently, optimization processes usually stop once sufficient improvements are achieved, without striving for perfection. Fortunately, significant gains often occur early in the optimization process, making it practical to stop before reaching <a href="Diminishing_returns" title="Diminishing returns">diminishing returns</a>.
</p>
<div class="mw-heading mw-heading2"><h2 id="Levels_of_optimization">Levels of optimization</h2></div>
<p>Optimization can occur at a number of levels. Typically the higher levels have greater impact, and are harder to change later on in a project, requiring significant changes or a complete rewrite if they need to be changed. Thus optimization can typically proceed via refinement from higher to lower, with initial gains being larger and achieved with less work, and later gains being smaller and requiring more work. However, in some cases overall performance depends on performance of very low-level portions of a program, and small changes at a late stage or early consideration of low-level details can have outsized impact. Typically some consideration is given to efficiency throughout a project&nbsp;– though this varies significantly&nbsp;– but major optimization is often considered a refinement to be done late, if ever. On longer-running projects there are typically cycles of optimization, where improving one area reveals limitations in another, and these are typically curtailed when performance is acceptable or gains become too small or costly. Best practices for optimization during iterative development cycles include continuous monitoring for performance issues coupled with regular performance testing.<sup id="cite_ref-3" class="reference"><a href="#cite_note-3"><span class="cite-bracket">[</span>3<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-4" class="reference"><a href="#cite_note-4"><span class="cite-bracket">[</span>4<span class="cite-bracket">]</span></a></sup>
</p><p>As performance is part of the specification of a program&nbsp;– a program that is unusably slow is not fit for purpose: a video game with 60&nbsp;Hz (frames-per-second) is acceptable, but 6 frames-per-second is unacceptably choppy&nbsp;– performance is a consideration from the start, to ensure that the system is able to deliver sufficient performance, and early prototypes need to have roughly acceptable performance for there to be confidence that the final system will (with optimization) achieve acceptable performance. This is sometimes omitted in the belief that optimization can always be done later, resulting in prototype systems that are far too slow&nbsp;– often by an <a href="Order_of_magnitude" title="Order of magnitude">order of magnitude</a> or more&nbsp;– and systems that ultimately are failures because they architecturally cannot achieve their performance goals, such as the <a href="Intel_432" class="mw-redirect" title="Intel 432">Intel 432</a> (1981); or ones that take years of work to achieve acceptable performance, such as Java (1995), which achieved performance comparable with native code only with <a href="HotSpot_(virtual_machine)" title="HotSpot (virtual machine)">HotSpot</a> (1999).<sup id="cite_ref-5" class="reference"><a href="#cite_note-5"><span class="cite-bracket">[</span>5<span class="cite-bracket">]</span></a></sup> The degree to which performance changes between prototype and production system, and how amenable it is to optimization, can be a significant source of uncertainty and risk.
</p>
<div class="mw-heading mw-heading3"><h3 id="Design_level">Design level</h3></div>
<p>At the highest level, the design may be optimized to make best use of the available resources, given goals, constraints, and expected use/load. The architectural design of a system overwhelmingly affects its performance. For example, a system that is network latency-bound (where network latency is the main constraint on overall performance) would be optimized to minimize network trips, ideally making a single request (or no requests, as in a <a href="Push_protocol" class="mw-redirect" title="Push protocol">push protocol</a>) rather than multiple roundtrips. Choice of design depends on the goals: when designing a <a href="Compiler" title="Compiler">compiler</a>, if fast compilation is the key priority, a <a href="One-pass_compiler" title="One-pass compiler">one-pass compiler</a> is faster than a <a href="Multi-pass_compiler" title="Multi-pass compiler">multi-pass compiler</a> (assuming same work), but if speed of output code is the goal, a slower multi-pass compiler fulfills the goal better, even though it takes longer itself. Choice of platform and programming language occur at this level, and changing them frequently requires a complete rewrite, though a modular system may allow rewrite of only some component&nbsp;– for example, for a Python program one may rewrite performance-critical sections in C. In a distributed system, choice of architecture (<a href="Client-server" class="mw-redirect" title="Client-server">client-server</a>, <a href="Peer-to-peer" title="Peer-to-peer">peer-to-peer</a>, etc.) occurs at the design level, and may be difficult to change, particularly if all components cannot be replaced in sync (e.g., old clients).
</p>
<div class="mw-heading mw-heading3"><h3 id="Algorithms_and_data_structures">Algorithms and data structures</h3></div>
<p>Given an overall design, a good choice of <a href="Algorithmic_efficiency" title="Algorithmic efficiency">efficient algorithms</a> and <a href="Data_structure" title="Data structure">data structures</a>, and efficient implementation of these algorithms and data structures comes next. After design, the choice of <a href="Algorithm" title="Algorithm">algorithms</a> and data structures affects efficiency more than any other aspect of the program. Generally data structures are more difficult to change than algorithms, as a data structure assumption and its performance assumptions are used throughout the program, though this can be minimized by the use of <a href="Abstract_data_type" title="Abstract data type">abstract data types</a> in function definitions, and keeping the concrete data structure definitions restricted to a few places. Changes in data structures mapped to a database may require schema migration and other complex software or infrastructure changes.<sup id="cite_ref-6" class="reference"><a href="#cite_note-6"><span class="cite-bracket">[</span>6<span class="cite-bracket">]</span></a></sup>
</p><p>For algorithms, this primarily consists of ensuring that algorithms are constant O(1), logarithmic O(log <i>n</i>), linear O(<i>n</i>), or in some cases log-linear O(<i>n</i> log <i>n</i>) in the input (both in space and time). Algorithms with quadratic complexity O(<i>n</i><sup>2</sup>) fail to scale, and even linear algorithms cause problems if repeatedly called, and are typically replaced with constant or logarithmic if possible.
</p><p>Beyond asymptotic order of growth, the constant factors matter: an asymptotically slower algorithm may be faster or smaller (because simpler) than an asymptotically faster algorithm when they are both faced with small input, which may be the case that occurs in reality. Often a <a href="Hybrid_algorithm" title="Hybrid algorithm">hybrid algorithm</a> will provide the best performance, due to this tradeoff changing with size.
</p><p>A general technique to improve performance is to avoid work. A good example is the use of a <a href="Fast_path" title="Fast path">fast path</a> for common cases, improving performance by avoiding unnecessary work. For example, using a simple text layout algorithm for Latin text, only switching to a complex layout algorithm for complex scripts, such as <a href="Devanagari" title="Devanagari">Devanagari</a>. Another important technique is caching, particularly <a href="Memoization" title="Memoization">memoization</a>, which avoids redundant computations. Because of the importance of caching, there are often many levels of caching in a system, which can cause problems from memory use, and correctness issues from stale caches.
</p>
<div class="mw-heading mw-heading3"><h3 id="Source_code_level">Source code level</h3></div>
<p>Beyond general algorithms and their implementation on an abstract machine, concrete source code level choices can make a significant difference. For example, on early C compilers, <code>while(1)</code> was slower than <code>for(;;)</code> for an unconditional loop, because <code>while(1)</code> evaluated 1 and then had a conditional jump which tested if it was true, while <code>for (;;)</code> had an unconditional jump . Some optimizations (such as this one) can nowadays be performed by <a href="Optimizing_compiler" title="Optimizing compiler">optimizing compilers</a>. This depends on the source language, the target machine language, and the compiler, and can be both difficult to understand or predict and changes over time; this is a key place where understanding of compilers and machine code can improve performance. <a href="Loop-invariant_code_motion" title="Loop-invariant code motion">Loop-invariant code motion</a> and <a href="Return_value_optimization" class="mw-redirect" title="Return value optimization">return value optimization</a> are examples of optimizations that reduce the need for auxiliary variables and can even result in faster performance by avoiding round-about optimizations.
</p>
<div class="mw-heading mw-heading3"><h3 id="Build_level">Build level</h3></div>
<p>Between the source and compile level, <a href="Directive_(programming)" title="Directive (programming)">directives</a> and <a href="Build_automation" title="Build automation">build flags</a> can be used to tune performance options in the source code and compiler respectively, such as using <a href="Preprocessor" title="Preprocessor">preprocessor</a> defines to disable unneeded software features, optimizing for specific processor models or hardware capabilities, or predicting <a href="Branch_(computer_science)" title="Branch (computer science)">branching</a>, for instance. Source-based software distribution systems such as <a href="Berkeley_Software_Distribution" title="Berkeley Software Distribution">BSD</a>'s <a href="Ports_collection" title="Ports collection">Ports</a> and <a href="Gentoo_Linux" title="Gentoo Linux">Gentoo</a>'s <a href="Portage_(software)" title="Portage (software)">Portage</a> can take advantage of this form of optimization.
</p>
<div class="mw-heading mw-heading3"><h3 id="Compile_level">Compile level</h3></div>
<p>Use of an <a href="Optimizing_compiler" title="Optimizing compiler">optimizing compiler</a> tends to ensure that the <a href="Executable_program" class="mw-redirect" title="Executable program">executable program</a> is optimized at least as much as the compiler can predict.
</p>
<div class="mw-heading mw-heading3"><h3 id="Assembly_level">Assembly level</h3></div>
<p>At the lowest level, writing code using an <a href="Assembly_language" title="Assembly language">assembly language</a>, designed for a particular hardware platform can produce the most efficient and compact code if the programmer takes advantage of the full repertoire of <a href="Machine_instruction" class="mw-redirect" title="Machine instruction">machine instructions</a>. Many <a href="Operating_system" title="Operating system">operating systems</a> used on <a href="Embedded_system" title="Embedded system">embedded systems</a> have been traditionally written in assembler code for this reason. Programs (other than very small programs) are seldom written from start to finish in assembly due to the time and cost involved. Most are compiled down from a high level language to assembly and hand optimized from there. When efficiency and size are less important large parts may be written in a high-level language.
</p><p>With more modern <a href="Optimizing_compiler" title="Optimizing compiler">optimizing compilers</a> and the greater complexity of recent <a href="CPU" class="mw-redirect" title="CPU">CPUs</a>, it is harder to write more efficient code than what the compiler generates, and few projects need this "ultimate" optimization step.
</p><p>Much of the code written today is intended to run on as many machines as possible. As a consequence, programmers and compilers don't always take advantage of the more efficient instructions provided by newer CPUs or quirks of older models. Additionally, assembly code tuned for a particular processor without using such instructions might still be suboptimal on a different processor, expecting a different tuning of the code.
</p><p>Typically today rather than writing in assembly language, programmers will use a <a href="Disassembler" title="Disassembler">disassembler</a> to analyze the output of a compiler and change the high-level source code so that it can be compiled more efficiently, or understand why it is inefficient.
</p>
<div class="mw-heading mw-heading3"><h3 id="Run_time">Run time</h3></div>
<p><a href="Just-in-time_compilation" title="Just-in-time compilation">Just-in-time</a> compilers can produce customized machine code based on run-time data, at the cost of compilation overhead. This technique dates to the earliest <a href="Regular_expression" title="Regular expression">regular expression</a> engines, and has become widespread with Java HotSpot and V8 for JavaScript. In some cases <a href="Adaptive_optimization" title="Adaptive optimization">adaptive optimization</a> may be able to perform <a href="Run_time_(program_lifecycle_phase)" class="mw-redirect" title="Run time (program lifecycle phase)">run time</a> optimization exceeding the capability of static compilers by dynamically adjusting parameters according to the actual input or other factors.
</p><p><a href="Profile-guided_optimization" title="Profile-guided optimization">Profile-guided optimization</a> is an ahead-of-time (AOT) compilation optimization technique based on run time profiles, and is similar to a static "average case" analog of the dynamic technique of adaptive optimization.
</p><p><a href="Self-modifying_code" title="Self-modifying code">Self-modifying code</a> can alter itself in response to run time conditions in order to optimize code; this was more common in assembly language programs.
</p><p>Some <a href="CPU_design" class="mw-redirect" title="CPU design">CPU designs</a> can perform some optimizations at run time. Some examples include <a href="Out-of-order_execution" title="Out-of-order execution">out-of-order execution</a>, <a href="Speculative_execution" title="Speculative execution">speculative execution</a>, <a href="Instruction_pipeline" class="mw-redirect" title="Instruction pipeline">instruction pipelines</a>, and <a href="Branch_predictor" title="Branch predictor">branch predictors</a>. Compilers can help the program take advantage of these CPU features, for example through <a href="Instruction_scheduling" title="Instruction scheduling">instruction scheduling</a>.
</p>
<div class="mw-heading mw-heading3"><h3 id="Platform_dependent_and_independent_optimizations">Platform dependent and independent optimizations</h3></div>
<p>Code optimization can be also broadly categorized as <a href="Computer_platform" class="mw-redirect" title="Computer platform">platform</a>-dependent and platform-independent techniques. While the latter ones are effective on most or all platforms, platform-dependent techniques use specific properties of one platform, or rely on parameters depending on the single platform or even on the single processor. Writing or producing different versions of the same code for different processors might therefore be needed. For instance, in the case of compile-level optimization, platform-independent techniques are generic techniques (such as <a href="Loop_unwinding" class="mw-redirect" title="Loop unwinding">loop unrolling</a>, reduction in function calls, memory efficient routines, reduction in conditions, etc.), that impact most CPU architectures in a similar way. A great example of platform-independent optimization has been shown with inner for loop, where it was observed that a loop with an inner for loop performs more computations per unit time than a loop without it or one with an inner while loop.<sup id="cite_ref-7" class="reference"><a href="#cite_note-7"><span class="cite-bracket">[</span>7<span class="cite-bracket">]</span></a></sup> Generally, these serve to reduce the total <a href="Instruction_path_length" title="Instruction path length">instruction path length</a> required to complete the program and/or reduce total memory usage during the process. On the other hand, platform-dependent techniques involve instruction scheduling, <a href="Instruction-level_parallelism" title="Instruction-level parallelism">instruction-level parallelism</a>, data-level parallelism, cache optimization techniques (i.e., parameters that differ among various platforms) and the optimal instruction scheduling might be different even on different processors of the same architecture.
</p>
<div class="mw-heading mw-heading2"><h2 id="Strength_reduction">Strength reduction</h2></div>
<p>Computational tasks can be performed in several different ways with varying efficiency. A more efficient version with equivalent functionality is known as a <a href="Strength_reduction" title="Strength reduction">strength reduction</a>. For example, consider the following <a href="C_(programming_language)" title="C (programming language)">C</a> code snippet whose intention is to obtain the sum of all integers from 1 to <var style="padding-right: 1px;">N</var>:
</p>
<div class="mw-highlight mw-highlight-lang-c mw-content-ltr" dir="ltr"><pre><span class="kt">int</span><span class="w"> </span><span class="n">i</span><span class="p">,</span><span class="w"> </span><span class="n">sum</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">0</span><span class="p">;</span>
<span class="k">for</span><span class="w"> </span><span class="p">(</span><span class="n">i</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span><span class="p">;</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">&lt;=</span><span class="w"> </span><span class="n">N</span><span class="p">;</span><span class="w"> </span><span class="o">++</span><span class="n">i</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="n">sum</span><span class="w"> </span><span class="o">+=</span><span class="w"> </span><span class="n">i</span><span class="p">;</span>
<span class="p">}</span>
<span class="n">printf</span><span class="p">(</span><span class="s">"sum: %d</span><span class="se">\n</span><span class="s">"</span><span class="p">,</span><span class="w"> </span><span class="n">sum</span><span class="p">);</span>
</pre></div>
<p>This code can (assuming no <a href="Arithmetic_overflow" class="mw-redirect" title="Arithmetic overflow">arithmetic overflow</a>) be rewritten using a mathematical formula like:
</p>
<div class="mw-highlight mw-highlight-lang-c mw-content-ltr" dir="ltr"><pre><span class="kt">int</span><span class="w"> </span><span class="n">sum</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">N</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="p">(</span><span class="mi">1</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="n">N</span><span class="p">)</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mi">2</span><span class="p">;</span>
<span class="n">printf</span><span class="p">(</span><span class="s">"sum: %d</span><span class="se">\n</span><span class="s">"</span><span class="p">,</span><span class="w"> </span><span class="n">sum</span><span class="p">);</span>
</pre></div>
<p>The optimization, sometimes performed automatically by an optimizing compiler, is to select a method (<a href="Algorithm" title="Algorithm">algorithm</a>) that is more computationally efficient, while retaining the same functionality. See <a href="Algorithmic_efficiency" title="Algorithmic efficiency">algorithmic efficiency</a> for a discussion of some of these techniques. However, a significant improvement in performance can often be achieved by removing extraneous functionality.
</p><p>Optimization is not always an obvious or intuitive process. In the example above, the "optimized" version might actually be slower than the original version if <var style="padding-right: 1px;">N</var> were sufficiently small and the particular hardware happens to be much faster at performing addition and <a href="Loop_(computing)" class="mw-redirect" title="Loop (computing)">looping</a> operations than multiplication and division.
</p>
<div class="mw-heading mw-heading2"><h2 id="Trade-offs">Trade-offs</h2></div>
<p>In some cases, however, optimization relies on using more elaborate algorithms, making use of "special cases" and special "tricks" and performing complex trade-offs. A "fully optimized" program might be more difficult to comprehend and hence may contain more <a href="Software_bug" title="Software bug">faults</a> than unoptimized versions. Beyond eliminating obvious antipatterns, some code level optimizations decrease maintainability.
</p><p>Optimization will generally focus on improving just one or two aspects of performance: execution time, memory usage, disk space, bandwidth, power consumption or some other resource. This will usually require a trade-off&nbsp;– where one factor is optimized at the expense of others. For example, increasing the size of <a href="Cache_(computing)" title="Cache (computing)">cache</a> improves run time performance, but also increases the memory consumption. Other common trade-offs include code clarity and conciseness.
</p><p>There are instances where the programmer performing the optimization must decide to make the software better for some operations but at the cost of making other operations less efficient. These trade-offs may sometimes be of a non-technical nature&nbsp;– such as when a competitor has published a <a href="Benchmark_(computing)" title="Benchmark (computing)">benchmark</a> result that must be beaten in order to improve commercial success but comes perhaps with the burden of making normal usage of the software less efficient. Such changes are sometimes jokingly referred to as <i>pessimizations</i>.
</p>
<div class="mw-heading mw-heading2"><h2 id="Bottlenecks">Bottlenecks</h2></div>
<p>Optimization may include finding a <a href="Bottleneck_(engineering)" title="Bottleneck (engineering)">bottleneck</a> in a system&nbsp;– a component that is the limiting factor on performance. In terms of code, this will often be a <a href="Hot_spot_(computer_science)" class="mw-redirect" title="Hot spot (computer science)">hot spot</a>&nbsp;– a critical part of the code that is the primary consumer of the needed resource&nbsp;– though it can be another factor, such as I/O latency or network bandwidth.
</p><p>In computer science, resource consumption often follows a form of <a href="Power_law" title="Power law">power law</a> distribution, and the <a href="Pareto_principle" title="Pareto principle">Pareto principle</a> can be applied to resource optimization by observing that 80% of the resources are typically used by 20% of the operations.<sup id="cite_ref-8" class="reference"><a href="#cite_note-8"><span class="cite-bracket">[</span>8<span class="cite-bracket">]</span></a></sup> In software engineering, it is often a better approximation that 90% of the execution time of a computer program is spent executing 10% of the code (known as the 90/10 law in this context).
</p><p>More complex algorithms and data structures perform well with many items, while simple algorithms are more suitable for small amounts of data — the setup, initialization time, and constant factors of the more complex algorithm can outweigh the benefit, and thus a <a href="Hybrid_algorithm" title="Hybrid algorithm">hybrid algorithm</a> or <a href="Adaptive_algorithm" title="Adaptive algorithm">adaptive algorithm</a> may be faster than any single algorithm. A performance profiler can be used to narrow down decisions about which functionality fits which conditions.<sup id="cite_ref-9" class="reference"><a href="#cite_note-9"><span class="cite-bracket">[</span>9<span class="cite-bracket">]</span></a></sup>
</p><p>Performance profiling therefore provides not only bottleneck detection but rather a variety of methods for optimization guidance. <a href="Empirical_algorithmics" title="Empirical algorithmics">Empirical algorithmics</a> is the practice of using empirical methods, typically performance profiling, to study the behavior of algorithms, for developer understanding that may lead to human-planned optimizations. <a href="Profile-guided_optimization" title="Profile-guided optimization">Profile-guided optimization</a> is the machine-driven use of profiling data as input to an optimizing compiler or interpreter. Some programming languages are associated with tools for profile-guided optimization.<sup id="cite_ref-10" class="reference"><a href="#cite_note-10"><span class="cite-bracket">[</span>10<span class="cite-bracket">]</span></a></sup> Some performance profiling methods emphasize enhancements based on <a href="Cache_(computing)" title="Cache (computing)">cache</a> utilization.<sup id="cite_ref-11" class="reference"><a href="#cite_note-11"><span class="cite-bracket">[</span>11<span class="cite-bracket">]</span></a></sup> Other benefits of performance profiling may include improved resource management and an enhanced user experience.<sup id="cite_ref-12" class="reference"><a href="#cite_note-12"><span class="cite-bracket">[</span>12<span class="cite-bracket">]</span></a></sup>
</p><p>In some cases, adding more <a href="Main_memory" class="mw-redirect" title="Main memory">memory</a> can help to make a program run faster. For example, a filtering program will commonly read each line and filter and output that line immediately. This only uses enough memory for one line, but performance is typically poor, due to the latency of each disk read. Caching the result is similarly effective, though also requiring larger memory use.
</p>
<div class="mw-heading mw-heading2"><h2 id="When_to_optimize">When to optimize</h2></div>
<p>Optimization can reduce <a href="Readability" title="Readability">readability</a> and add code that is used only to improve the <a href="Computer_performance" title="Computer performance">performance</a>. This may complicate programs or systems, making them harder to maintain and debug. As a result, optimization or performance tuning is often performed at the end of the <a href="Development_stage" class="mw-redirect" title="Development stage">development stage</a>.
</p><p><a href="Donald_Knuth" title="Donald Knuth">Donald Knuth</a> made the following two statements on optimization:
</p>
<blockquote><p>"We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil. Yet we should not pass up our opportunities in that critical 3%"<sup id="cite_ref-autogenerated268_13-0" class="reference"><a href="#cite_note-autogenerated268-13"><span class="cite-bracket">[</span>13<span class="cite-bracket">]</span></a></sup></p></blockquote>
<p>(He also attributed the quote to <a href="Tony_Hoare" title="Tony Hoare">Tony Hoare</a> several years later,<sup id="cite_ref-14" class="reference"><a href="#cite_note-14"><span class="cite-bracket">[</span>14<span class="cite-bracket">]</span></a></sup> although this might have been an error as Hoare disclaims having coined the phrase.<sup id="cite_ref-15" class="reference"><a href="#cite_note-15"><span class="cite-bracket">[</span>15<span class="cite-bracket">]</span></a></sup>)
</p>
<blockquote><p> "In established engineering disciplines a 12% improvement, easily obtained, is never considered marginal and I believe the same viewpoint should prevail in software engineering"<sup id="cite_ref-autogenerated268_13-1" class="reference"><a href="#cite_note-autogenerated268-13"><span class="cite-bracket">[</span>13<span class="cite-bracket">]</span></a></sup></p></blockquote>
<p>"Premature optimization" is a phrase used to describe a situation where a programmer lets performance considerations affect the design of a piece of code. This can result in a design that is not as clean as it could have been or code that is incorrect, because the code is complicated by the optimization and the programmer is distracted by optimizing.
</p><p>When deciding whether to optimize a specific part of the program, <a href="Amdahl's_Law" class="mw-redirect" title="Amdahl's Law">Amdahl's Law</a> should always be considered: the impact on the overall program depends very much on how much time is actually spent in that specific part, which is not always clear from looking at the code without a <a href="Profiling_(computer_programming)" title="Profiling (computer programming)">performance analysis</a>.
</p><p>A better approach is therefore to design first, code from the design and then <a href="Profiling_(computer_programming)" title="Profiling (computer programming)">profile</a>/<a href="Benchmark_(computing)" title="Benchmark (computing)">benchmark</a> the resulting code to see which parts should be optimized. A simple and elegant design is often easier to optimize at this stage, and profiling may reveal unexpected performance problems that would not have been addressed by premature optimization.
</p><p>In practice, it is often necessary to keep performance goals in mind when first designing software, but the programmer balances the goals of design and optimization.
</p><p>Modern compilers and operating systems are so efficient that the intended performance increases often fail to materialize. As an example, caching data at the application level that is again cached at the operating system level does not yield improvements in execution. Even so, it is a rare case when the programmer will remove failed optimizations from production code. It is also true that advances in hardware will more often than not obviate any potential improvements, yet the obscuring code will persist into the future long after its purpose has been negated.
</p>
<div class="mw-heading mw-heading2"><h2 id="Macros">Macros</h2></div>
<p>Optimization during code development using <a href="Macro_(computer_science)" title="Macro (computer science)">macros</a> takes on different forms in different languages.
</p><p>In some procedural languages, such as <a href="C_(programming_language)" title="C (programming language)">C</a> and <a href="C%2B%2B" title="C++">C++</a>, macros are implemented using token substitution. Nowadays, <a href="Inline_function" class="mw-redirect" title="Inline function">inline functions</a> can be used as a <a href="Type_safe" class="mw-redirect" title="Type safe">type safe</a> alternative in many cases. In both cases, the inlined function body can then undergo further compile-time optimizations by the compiler, including <a href="Constant_folding" title="Constant folding">constant folding</a>, which may move some computations to compile time.
</p><p>In many <a href="Functional_programming" title="Functional programming">functional programming</a> languages, macros are implemented using parse-time substitution of parse trees/abstract syntax trees, which it is claimed makes them safer to use. Since in many cases interpretation is used, that is one way to ensure that such computations are only performed at parse-time, and sometimes the only way.
</p><p><a href="Lisp_programming_language" class="mw-redirect" title="Lisp programming language">Lisp</a> originated this style of macro, and such macros are often called "Lisp-like macros". A similar effect can be achieved by using <a href="Template_metaprogramming" title="Template metaprogramming">template metaprogramming</a> in <a href="C%2B%2B" title="C++">C++</a>.
</p><p>In both cases, work is moved to compile-time. The difference between <a href="C_(programming_language)" title="C (programming language)">C</a> macros on one side, and Lisp-like macros and <a href="C%2B%2B" title="C++">C++</a> <a href="Template_metaprogramming" title="Template metaprogramming">template metaprogramming</a> on the other side, is that the latter tools allow performing arbitrary computations at compile-time/parse-time, while expansion of <a href="C_(programming_language)" title="C (programming language)">C</a> macros does not perform any computation, and relies on the optimizer ability to perform it. Additionally, <a href="C_(programming_language)" title="C (programming language)">C</a> macros do not directly support <a href="Recursion_(computer_science)" title="Recursion (computer science)">recursion</a> or <a href="Iteration" title="Iteration">iteration</a>, so are not <a href="Turing_complete" class="mw-redirect" title="Turing complete">Turing complete</a>.
</p><p>As with any optimization, however, it is often difficult to predict where such tools will have the most impact before a project is complete.
</p>
<div class="mw-heading mw-heading2"><h2 id="Automated_and_manual_optimization">Automated and manual optimization</h2></div>
<style data-mw-deduplicate="TemplateStyles:r1236090951">
/* start https://en.wikipedia.org/ */


.mw-parser-output .hatnote{font-style:italic}.mw-parser-output div.hatnote{padding-left:1.6em;margin-bottom:0.5em}.mw-parser-output .hatnote i{font-style:normal}.mw-parser-output .hatnote+link+.hatnote{margin-top:-0.5em}@media print{body.ns-0 .mw-parser-output .hatnote{display:none!important}}


/* end https://en.wikipedia.org/ */
</style><div role="note" class="hatnote navigation-not-searchable">Main article: <a href="Optimizing_compiler" title="Optimizing compiler">Optimizing compiler</a></div>
<p><i>See also Category:Compiler optimizations</i>
</p><p>Optimization can be automated by compilers or performed by programmers. Gains are usually limited for local optimization, and larger for global optimizations. Usually, the most powerful optimization is to find a superior <a href="Algorithm" title="Algorithm">algorithm</a>.
</p><p>Optimizing a whole system is usually undertaken by programmers because it is too complex for automated optimizers. In this situation, programmers or <a href="System_administrator" title="System administrator">system administrators</a> explicitly change code so that the overall system performs better. Although it can produce better efficiency, it is far more expensive than automated optimizations. Since many parameters influence the program performance, the program optimization space is large. Meta-heuristics and machine learning are used to address the complexity of program optimization.<sup id="cite_ref-16" class="reference"><a href="#cite_note-16"><span class="cite-bracket">[</span>16<span class="cite-bracket">]</span></a></sup>
</p><p>Use a <a href="Profiler_(computer_science)" class="mw-redirect" title="Profiler (computer science)">profiler</a> (or <a href="Profiling_(computer_programming)" title="Profiling (computer programming)">performance analyzer</a>) to find the sections of the program that are taking the most resources&nbsp;– the <i>bottleneck</i>. Programmers sometimes believe they have a clear idea of where the bottleneck is, but intuition is frequently wrong. Optimizing an unimportant piece of code will typically do little to help the overall performance.
</p><p>When the bottleneck is localized, optimization usually starts with a rethinking of the algorithm used in the program. More often than not, a particular algorithm can be specifically tailored to a particular problem, yielding better performance than a generic algorithm. For example, the task of sorting a huge list of items is usually done with a <a href="Quicksort" title="Quicksort">quicksort</a> routine, which is one of the most efficient generic algorithms. But if some characteristic of the items is exploitable (for example, they are already arranged in some particular order), a different method can be used, or even a custom-made sort routine.
</p><p>After the programmer is reasonably sure that the best algorithm is selected, code optimization can start. Loops can be unrolled (for lower loop overhead, although this can often lead to <i>lower</i> speed if it overloads the <a href="CPU_cache" title="CPU cache">CPU cache</a>), data types as small as possible can be used, integer arithmetic can be used instead of floating-point, and so on. (See <a href="Algorithmic_efficiency" title="Algorithmic efficiency">algorithmic efficiency</a> article for these and other techniques.)
</p><p>Performance bottlenecks can be due to language limitations rather than algorithms or data structures used in the program. Sometimes, a critical part of the program can be re-written in a different <a href="Programming_language" title="Programming language">programming language</a> that gives more direct access to the underlying machine. For example, it is common for very <a href="High-level_programming_language" title="High-level programming language">high-level</a> languages like <a href="Python_(programming_language)" title="Python (programming language)">Python</a> to have modules written in <a href="C_(programming_language)" title="C (programming language)">C</a> for greater speed. Programs already written in C can have modules written in <a href="Assembly_language" title="Assembly language">assembly</a>. Programs written in <a href="D_programming_language" class="mw-redirect" title="D programming language">D</a> can use the <a href="Inline_assembler" title="Inline assembler">inline assembler</a>.
</p><p>Rewriting sections "pays off" in these circumstances because of a general "<a href="Rule_of_thumb" title="Rule of thumb">rule of thumb</a>" known as the 90/10 law, which states that 90% of the time is spent in 10% of the code, and only 10% of the time in the remaining 90% of the code. So, putting intellectual effort into optimizing just a small part of the program can have a huge effect on the overall speed&nbsp;– if the correct part(s) can be located.
</p><p>Manual optimization sometimes has the side effect of undermining readability. Thus code optimizations should be carefully documented (preferably using in-line comments), and their effect on future development evaluated.
</p><p>The program that performs an automated optimization is called an <b>optimizer</b>. Most optimizers are embedded in compilers and operate during compilation. Optimizers can often tailor the generated code to specific processors.
</p><p>Today, automated optimizations are almost exclusively limited to <a href="Compiler_optimization" class="mw-redirect" title="Compiler optimization">compiler optimization</a>. However, because compiler optimizations are usually limited to a fixed set of rather general optimizations, there is considerable demand for optimizers which can accept descriptions of problem and language-specific optimizations, allowing an engineer to specify custom optimizations. Tools that accept descriptions of optimizations are called <a href="Program_transformation" title="Program transformation">program transformation</a> systems and are beginning to be applied to real software systems such as C++.
</p><p>Some high-level languages (<a href="Eiffel_(programming_language)" title="Eiffel (programming language)">Eiffel</a>, <a href="Esterel" title="Esterel">Esterel</a>) optimize their programs by using an <a href="Intermediate_language" class="mw-redirect" title="Intermediate language">intermediate language</a>.
</p><p><a href="Grid_computing" title="Grid computing">Grid computing</a> or <a href="Distributed_computing" title="Distributed computing">distributed computing</a> aims to optimize the whole system, by moving tasks from computers with high usage to computers with idle time.
</p>
<div class="mw-heading mw-heading2"><h2 id="Time_taken_for_optimization">Time taken for optimization</h2></div>
<p>Sometimes, the time taken to undertake optimization therein itself may be an issue.
</p><p>Optimizing existing code usually does not add new features, and worse, it might add new <a href="Software_bug" title="Software bug">bugs</a> in previously working code (as any change might). Because manually optimized code might sometimes have less "readability" than unoptimized code, optimization might impact maintainability of it as well. Optimization comes at a price and it is important to be sure that the investment is worthwhile.
</p><p>An automatic optimizer (or <a href="Optimizing_compiler" title="Optimizing compiler">optimizing compiler</a>, a program that performs code optimization) may itself have to be optimized, either to further improve the efficiency of its target programs or else speed up its own operation. A compilation performed with optimization "turned on" usually takes longer, although this is usually only a problem when programs are quite large.
</p><p>In particular, for <a href="Just-in-time_compiler" class="mw-redirect" title="Just-in-time compiler">just-in-time compilers</a> the performance of the <a href="Run_time_environment" class="mw-redirect" title="Run time environment">run time</a> compile component, executing together with its target code, is the key to improving overall execution speed.
</p>
<div class="mw-heading mw-heading2"><h2 id="See_also">See also</h2></div>
<style data-mw-deduplicate="TemplateStyles:r1184024115">
/* start https://en.wikipedia.org/ */


.mw-parser-output .div-col{margin-top:0.3em;column-width:30em}.mw-parser-output .div-col-small{font-size:90%}.mw-parser-output .div-col-rules{column-rule:1px solid #aaa}.mw-parser-output .div-col dl,.mw-parser-output .div-col ol,.mw-parser-output .div-col ul{margin-top:0}.mw-parser-output .div-col li,.mw-parser-output .div-col dd{page-break-inside:avoid;break-inside:avoid-column}


/* end https://en.wikipedia.org/ */
</style><div class="div-col div-col-small" style="column-width: 20em;">
<ul><li><a href="Benchmark_(computing)" title="Benchmark (computing)">Benchmark</a>&nbsp;– Standardized performance evaluation</li>
<li><a href="Cache_(computing)" title="Cache (computing)">Cache (computing)</a>&nbsp;– Additional storage that enables faster access to main storage</li>
<li><a href="Empirical_algorithmics" title="Empirical algorithmics">Empirical algorithmics</a>&nbsp;– Use of empirical methods to study algorithms</li>
<li><a href="Optimizing_compiler" title="Optimizing compiler">Optimizing compiler</a>&nbsp;– Compiler that optimizes generated code</li>
<li><a href="Performance_engineering" title="Performance engineering">Performance engineering</a>&nbsp;– Encompasses the techniques applied during a systems development life cycle</li>
<li><a href="Performance_prediction" title="Performance prediction">Performance prediction</a></li>
<li><a href="Performance_tuning" title="Performance tuning">Performance tuning</a></li>
<li><a href="Profile-guided_optimization" title="Profile-guided optimization">Profile-guided optimization</a>&nbsp;– Compiler optimization technique</li>
<li><a href="Software_development" title="Software development">Software development</a>&nbsp;– Creation and maintenance of software</li>
<li><a href="Software_performance_testing" title="Software performance testing">Software performance testing</a>&nbsp;– Testing performance under a given workload</li>
<li><a href="Static_code_analysis" class="mw-redirect" title="Static code analysis">Static code analysis</a>&nbsp;– Analysis of computer programs without executing them<span style="display:none" class="category-annotation-with-redirected-description">Pages displaying short descriptions of redirect targets</span></li></ul>
</div>
<div class="mw-heading mw-heading2"><h2 id="References">References</h2></div>
<style data-mw-deduplicate="TemplateStyles:r1239543626">
/* start https://en.wikipedia.org/ */


.mw-parser-output .reflist{margin-bottom:0.5em;list-style-type:decimal}@media screen{.mw-parser-output .reflist{font-size:90%}}.mw-parser-output .reflist .references{font-size:100%;margin-bottom:0;list-style-type:inherit}.mw-parser-output .reflist-columns-2{column-width:30em}.mw-parser-output .reflist-columns-3{column-width:25em}.mw-parser-output .reflist-columns{margin-top:0.3em}.mw-parser-output .reflist-columns ol{margin-top:0}.mw-parser-output .reflist-columns li{page-break-inside:avoid;break-inside:avoid-column}.mw-parser-output .reflist-upper-alpha{list-style-type:upper-alpha}.mw-parser-output .reflist-upper-roman{list-style-type:upper-roman}.mw-parser-output .reflist-lower-alpha{list-style-type:lower-alpha}.mw-parser-output .reflist-lower-greek{list-style-type:lower-greek}.mw-parser-output .reflist-lower-roman{list-style-type:lower-roman}


/* end https://en.wikipedia.org/ */
</style><div class="reflist">
<div class="mw-references-wrap mw-references-columns"><ol class="references">
<li id="cite_note-1"><span class="mw-cite-backlink"><b><a href="#cite_ref-1">^</a></b></span> <span class="reference-text"><a href="Robert_Sedgewick_(computer_scientist)" title="Robert Sedgewick (computer scientist)">Robert Sedgewick</a>, <i>Algorithms</i>, 1984, p. 84.</span>
</li>
<li id="cite_note-2"><span class="mw-cite-backlink"><b><a href="#cite_ref-2">^</a></b></span> <span class="reference-text"><style data-mw-deduplicate="TemplateStyles:r1238218222">
/* start https://en.wikipedia.org/ */


.mw-parser-output cite.citation{font-style:inherit;word-wrap:break-word}.mw-parser-output .citation q{quotes:"\"""\"""'""'"}.mw-parser-output .citation:target{background-color:rgba(0,127,255,0.133)}.mw-parser-output .id-lock-free.id-lock-free a{background:url("./mw/Lock-green.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-limited.id-lock-limited a,.mw-parser-output .id-lock-registration.id-lock-registration a{background:url("./mw/Lock-gray-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-subscription.id-lock-subscription a{background:url("./mw/Lock-red-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .cs1-ws-icon a{background:url("./mw/Wikisource-logo.svg")right 0.1em center/12px no-repeat}body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-free a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-limited a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-registration a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-subscription a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .cs1-ws-icon a{background-size:contain;padding:0 1em 0 0}.mw-parser-output .cs1-code{color:inherit;background:inherit;border:none;padding:inherit}.mw-parser-output .cs1-hidden-error{display:none;color:var(--color-error,#d33)}.mw-parser-output .cs1-visible-error{color:var(--color-error,#d33)}.mw-parser-output .cs1-maint{display:none;color:#085;margin-left:0.3em}.mw-parser-output .cs1-kern-left{padding-left:0.2em}.mw-parser-output .cs1-kern-right{padding-right:0.2em}.mw-parser-output .citation .mw-selflink{font-weight:inherit}@media screen{.mw-parser-output .cs1-format{font-size:95%}html.skin-theme-clientpref-night .mw-parser-output .cs1-maint{color:#18911f}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .cs1-maint{color:#18911f}}


/* end https://en.wikipedia.org/ */
</style><cite id="CITEREFAntoniouLu2021" class="citation book cs1">Antoniou, Andreas; Lu, Wu-Sheng (2021). <a rel="nofollow" class="external text" href="https://link.springer.com/content/pdf/10.1007/978-1-0716-0843-2.pdf"><i>Practical Optimization</i></a> <span class="cs1-format">(PDF)</span>. Texts in Computer Science (2nd&nbsp;ed.). <a href="Springer_Publishing" title="Springer Publishing">Springer</a>. p.&nbsp;1. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1007%2F978-1-0716-0843-2">10.1007/978-1-0716-0843-2</a>. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>978-1-0716-0841-8</bdi>.</cite></span>
</li>
<li id="cite_note-3"><span class="mw-cite-backlink"><b><a href="#cite_ref-3">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://senlainc.com/blog/performance-optimization-in-software-development/#best-practices-for-performance-optimization">"Performance Optimization in Software Development: Speeding Up Your Applications"</a><span class="reference-accessdate">. Retrieved <span class="nowrap">12 July</span> 2025</span>.</cite></span>
</li>
<li id="cite_note-4"><span class="mw-cite-backlink"><b><a href="#cite_ref-4">^</a></b></span> <span class="reference-text"><cite id="CITEREFAgrawal,_Amit" class="citation web cs1">Agrawal, Amit. <a rel="nofollow" class="external text" href="https://www.developers.dev/tech-talk/implement-a-system-for-monitoring-application.html">"Maximizing Efficiency: Implementing a Performance Monitoring System"</a><span class="reference-accessdate">. Retrieved <span class="nowrap">12 July</span> 2025</span>.</cite></span>
</li>
<li id="cite_note-5"><span class="mw-cite-backlink"><b><a href="#cite_ref-5">^</a></b></span> <span class="reference-text"><cite id="CITEREFDüppe,_Ingo" class="citation web cs1">Düppe, Ingo. <a rel="nofollow" class="external text" href="https://javapro.io/2025/04/07/hitchhikers-guide-to-java-performance">"Hitchhiker's Guide to Java Performance: The Past, the Present, and the Future"</a><span class="reference-accessdate">. Retrieved <span class="nowrap">12 July</span> 2025</span>.</cite></span>
</li>
<li id="cite_note-6"><span class="mw-cite-backlink"><b><a href="#cite_ref-6">^</a></b></span> <span class="reference-text"><cite id="CITEREFMullins,_Craig_S." class="citation web cs1">Mullins, Craig S. <a rel="nofollow" class="external text" href="https://www.dbta.com/Columns/DBA-Corner/The-Impact-of-Change-on-Database-Structures-101931.aspx">"The Impact of Change on Database Structures"</a><span class="reference-accessdate">. Retrieved <span class="nowrap">12 July</span> 2025</span>.</cite></span>
</li>
<li id="cite_note-7"><span class="mw-cite-backlink"><b><a href="#cite_ref-7">^</a></b></span> <span class="reference-text"><cite id="CITEREFAdewumi2018" class="citation journal cs1">Adewumi, Tosin P. (2018-08-01). <a rel="nofollow" class="external text" href="https://doi.org/10.1515%2Fcomp-2018-0004">"Inner loop program construct: A faster way for program execution"</a>. <i>Open Computer Science</i>. <b>8</b> (1): <span class="nowrap">115–</span>122. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://doi.org/10.1515%2Fcomp-2018-0004">10.1515/comp-2018-0004</a></span>.</cite></span>
</li>
<li id="cite_note-8"><span class="mw-cite-backlink"><b><a href="#cite_ref-8">^</a></b></span> <span class="reference-text"><cite id="CITEREFWescott2013" class="citation book cs1">Wescott, Bob (2013). <i>The Every Computer Performance Book, Chapter 3: Useful laws</i>. <a href="CreateSpace" title="CreateSpace">CreateSpace</a>. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>978-1482657753</bdi>.</cite></span>
</li>
<li id="cite_note-9"><span class="mw-cite-backlink"><b><a href="#cite_ref-9">^</a></b></span> <span class="reference-text"><cite id="CITEREFKrauss,_Kirk_J." class="citation web cs1">Krauss, Kirk J. <a rel="nofollow" class="external text" href="http://www.developforperformance.com/PerformanceProfilingWithAFocus.html#FittingTheSituation">"Performance Profiling with a Focus"</a><span class="reference-accessdate">. Retrieved <span class="nowrap">15 August</span> 2017</span>.</cite></span>
</li>
<li id="cite_note-10"><span class="mw-cite-backlink"><b><a href="#cite_ref-10">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://doc.rust-lang.org/beta/rustc/profile-guided-optimization.html">"Profile-guided Optimization"</a><span class="reference-accessdate">. Retrieved <span class="nowrap">12 July</span> 2025</span>.</cite></span>
</li>
<li id="cite_note-11"><span class="mw-cite-backlink"><b><a href="#cite_ref-11">^</a></b></span> <span class="reference-text"><cite id="CITEREFThe_Valgrind_Developers2006" class="citation book cs1">The Valgrind Developers (2006). "5.2.2". <a rel="nofollow" class="external text" href="https://www.cs.cmu.edu/afs/cs.cmu.edu/project/cmt-40/Nice/RuleRefinement/bin/valgrind-3.2.0/docs/html/cl-manual.html#cl-manual.tools"><i>Valgrind User Manual</i></a>. Network Theory Ltd.</cite></span>
</li>
<li id="cite_note-12"><span class="mw-cite-backlink"><b><a href="#cite_ref-12">^</a></b></span> <span class="reference-text"><cite id="CITEREFKodlekere,_Ranjana" class="citation web cs1">Kodlekere, Ranjana. <a rel="nofollow" class="external text" href="https://testsigma.com/blog/performance-profiling/#benefits-of-performance-profiling">"Performance Profiling: Explained with Stages"</a><span class="reference-accessdate">. Retrieved <span class="nowrap">12 July</span> 2025</span>.</cite></span>
</li>
<li id="cite_note-autogenerated268-13"><span class="mw-cite-backlink">^ <a href="#cite_ref-autogenerated268_13-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-autogenerated268_13-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><cite id="CITEREFKnuth1974" class="citation journal cs1">Knuth, Donald (December 1974). "Structured Programming with go to Statements". <i>ACM Computing Surveys</i>. <b>6</b> (4): 268. <a href="CiteSeerX_(identifier)" class="mw-redirect" title="CiteSeerX (identifier)">CiteSeerX</a>&nbsp;<span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.103.6084">10.1.1.103.6084</a></span>. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1145%2F356635.356640">10.1145/356635.356640</a>. <a href="S2CID_(identifier)" class="mw-redirect" title="S2CID (identifier)">S2CID</a>&nbsp;<a rel="nofollow" class="external text" href="https://api.semanticscholar.org/CorpusID:207630080">207630080</a>.</cite></span>
</li>
<li id="cite_note-14"><span class="mw-cite-backlink"><b><a href="#cite_ref-14">^</a></b></span> <span class="reference-text"><i>The Errors of <a href="TeX" title="TeX">TeX</a></i>, in <i>Software—Practice &amp; Experience</i>, Volume 19, Issue 7 (July 1989), pp. 607–685, reprinted in his book Literate Programming (p. 276).</span>
</li>
<li id="cite_note-15"><span class="mw-cite-backlink"><b><a href="#cite_ref-15">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://hans.gerwitz.com/2004/08/12/premature-optimization-is-the-root-of-all-evil.html">"Premature optimization is the root of all evil"</a>. <i>hans.gerwitz.com</i><span class="reference-accessdate">. Retrieved <span class="nowrap">2020-12-18</span></span>. <q>Hoare, however, did not claim it when I queried him in January of 2004</q></cite></span>
</li>
<li id="cite_note-16"><span class="mw-cite-backlink"><b><a href="#cite_ref-16">^</a></b></span> <span class="reference-text"><cite id="CITEREFMemetiPllanaBinottoKołodziej2018" class="citation journal cs1">Memeti, Suejb; Pllana, Sabri; Binotto, Alécio; Kołodziej, Joanna; <a href="Ivona_Brandi%C4%87" title="Ivona Brandić">Brandic, Ivona</a> (26 April 2018). "Using meta-heuristics and machine learning for software optimization of parallel computing systems: a systematic literature review". <i>Computing</i>. <b>101</b> (8). Springer Vienna: <span class="nowrap">893–</span>936. <a href="ArXiv_(identifier)" class="mw-redirect" title="ArXiv (identifier)">arXiv</a>:<span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://arxiv.org/abs/1801.09444">1801.09444</a></span>. <a href="Bibcode_(identifier)" class="mw-redirect" title="Bibcode (identifier)">Bibcode</a>:<a rel="nofollow" class="external text" href="https://ui.adsabs.harvard.edu/abs/2018arXiv180109444M">2018arXiv180109444M</a>. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1007%2Fs00607-018-0614-9">10.1007/s00607-018-0614-9</a>. <a href="S2CID_(identifier)" class="mw-redirect" title="S2CID (identifier)">S2CID</a>&nbsp;<a rel="nofollow" class="external text" href="https://api.semanticscholar.org/CorpusID:13868111">13868111</a>.</cite></span>
</li>
</ol></div></div>
<div class="mw-heading mw-heading2"><h2 id="Further_reading">Further reading</h2></div>
<style data-mw-deduplicate="TemplateStyles:r1290876196">
/* start https://en.wikipedia.org/ */


.mw-parser-output .side-box{margin:4px 0;box-sizing:border-box;border:1px solid #aaa;font-size:88%;line-height:1.25em;background-color:var(--background-color-interactive-subtle,#f8f9fa);display:flow-root}.mw-parser-output .infobox .side-box{font-size:100%}.mw-parser-output .side-box-abovebelow,.mw-parser-output .side-box-text{padding:0.25em 0.9em}.mw-parser-output .side-box-image{padding:2px 0 2px 0.9em;text-align:center}.mw-parser-output .side-box-imageright{padding:2px 0.9em 2px 0;text-align:center}@media(min-width:500px){.mw-parser-output .side-box-flex{display:flex;align-items:center}.mw-parser-output .side-box-text{flex:1;min-width:0}}@media(min-width:720px){.mw-parser-output .side-box{width:238px}.mw-parser-output .side-box-right{clear:right;float:right;margin-left:1em}.mw-parser-output .side-box-left{margin-right:1em}}


/* end https://en.wikipedia.org/ */
</style><style data-mw-deduplicate="TemplateStyles:r1237033735">
/* start https://en.wikipedia.org/ */


@media print{body.ns-0 .mw-parser-output .sistersitebox{display:none!important}}@media screen{html.skin-theme-clientpref-night .mw-parser-output .sistersitebox img[src*="Wiktionary-logo-en-v2.svg"]{background-color:white}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .sistersitebox img[src*="Wiktionary-logo-en-v2.svg"]{background-color:white}}


/* end https://en.wikipedia.org/ */
</style><div class="side-box side-box-right sistersitebox"><style data-mw-deduplicate="TemplateStyles:r1126788409">
/* start https://en.wikipedia.org/ */


.mw-parser-output .plainlist ol,.mw-parser-output .plainlist ul{line-height:inherit;list-style:none;margin:0;padding:0}.mw-parser-output .plainlist ol li,.mw-parser-output .plainlist ul li{margin-bottom:0}


/* end https://en.wikipedia.org/ */
</style>
<div class="side-box-flex">
<div class="side-box-image"><span class="noviewer" typeof="mw:File"></span></div>
<div class="side-box-text plainlist">Wikibooks has a book on the topic of: <i><b><a href="https://en.wikibooks.org/wiki/Optimizing_Code_for_Speed" class="extiw external" title="wikibooks:Optimizing Code for Speed">Optimizing Code for Speed</a></b></i></div></div>
</div>
<ul><li><a href="Jon_Bentley_(computer_scientist)" title="Jon Bentley (computer scientist)">Jon Bentley</a>: <i>Writing Efficient Programs</i>, <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>0-13-970251-2</bdi>.</li>
<li><a href="Donald_Knuth" title="Donald Knuth">Donald Knuth</a>: <i><a href="The_Art_of_Computer_Programming" title="The Art of Computer Programming">The Art of Computer Programming</a></i></li>
<li><a rel="nofollow" class="external text" href="http://www.ece.cmu.edu/~franzf/papers/gttse07.pdf">How To Write Fast Numerical Code: A Small Introduction</a></li>
<li><a rel="nofollow" class="external text" href="http://people.redhat.com/drepper/cpumemory.pdf">"What Every Programmer Should Know About Memory"</a> by Ulrich Drepper&nbsp;– explains the structure of modern memory subsystems and suggests how to utilize them efficiently</li>
<li><a rel="nofollow" class="external text" href="http://icl.cs.utk.edu/~mucci/latest/pubs/Notur2009-new.pdf">"Linux Multicore Performance Analysis and Optimization in a Nutshell"</a>, presentation slides by Philip Mucci</li>
<li><a rel="nofollow" class="external text" href="http://www.azillionmonkeys.com/qed/optimize.html">Programming Optimization</a> by Paul Hsieh</li>
<li><a rel="nofollow" class="external text" href="http://www.new-npac.org/projects/cdroms/cewes-1999-06-vol1/nhse/hpccsurvey/orgs/sgi/bentley.html">Writing efficient programs ("Bentley's Rules")</a> by <a href="Jon_Bentley_(computer_scientist)" title="Jon Bentley (computer scientist)">Jon Bentley</a></li>
<li><a rel="nofollow" class="external text" href="http://queue.acm.org/detail.cfm?id=1117403">"Performance Anti-Patterns"</a> by Bart Smaalders</li></ul>
<div class="navbox-styles"><style data-mw-deduplicate="TemplateStyles:r1129693374">
/* start https://en.wikipedia.org/ */


.mw-parser-output .hlist dl,.mw-parser-output .hlist ol,.mw-parser-output .hlist ul{margin:0;padding:0}.mw-parser-output .hlist dd,.mw-parser-output .hlist dt,.mw-parser-output .hlist li{margin:0;display:inline}.mw-parser-output .hlist.inline,.mw-parser-output .hlist.inline dl,.mw-parser-output .hlist.inline ol,.mw-parser-output .hlist.inline ul,.mw-parser-output .hlist dl dl,.mw-parser-output .hlist dl ol,.mw-parser-output .hlist dl ul,.mw-parser-output .hlist ol dl,.mw-parser-output .hlist ol ol,.mw-parser-output .hlist ol ul,.mw-parser-output .hlist ul dl,.mw-parser-output .hlist ul ol,.mw-parser-output .hlist ul ul{display:inline}.mw-parser-output .hlist .mw-empty-li{display:none}.mw-parser-output .hlist dt::after{content:": "}.mw-parser-output .hlist dd::after,.mw-parser-output .hlist li::after{content:" · ";font-weight:bold}.mw-parser-output .hlist dd:last-child::after,.mw-parser-output .hlist dt:last-child::after,.mw-parser-output .hlist li:last-child::after{content:none}.mw-parser-output .hlist dd dd:first-child::before,.mw-parser-output .hlist dd dt:first-child::before,.mw-parser-output .hlist dd li:first-child::before,.mw-parser-output .hlist dt dd:first-child::before,.mw-parser-output .hlist dt dt:first-child::before,.mw-parser-output .hlist dt li:first-child::before,.mw-parser-output .hlist li dd:first-child::before,.mw-parser-output .hlist li dt:first-child::before,.mw-parser-output .hlist li li:first-child::before{content:" (";font-weight:normal}.mw-parser-output .hlist dd dd:last-child::after,.mw-parser-output .hlist dd dt:last-child::after,.mw-parser-output .hlist dd li:last-child::after,.mw-parser-output .hlist dt dd:last-child::after,.mw-parser-output .hlist dt dt:last-child::after,.mw-parser-output .hlist dt li:last-child::after,.mw-parser-output .hlist li dd:last-child::after,.mw-parser-output .hlist li dt:last-child::after,.mw-parser-output .hlist li li:last-child::after{content:")";font-weight:normal}.mw-parser-output .hlist ol{counter-reset:listitem}.mw-parser-output .hlist ol>li{counter-increment:listitem}.mw-parser-output .hlist ol>li::before{content:" "counter(listitem)"\a0 "}.mw-parser-output .hlist dd ol>li:first-child::before,.mw-parser-output .hlist dt ol>li:first-child::before,.mw-parser-output .hlist li ol>li:first-child::before{content:" ("counter(listitem)"\a0 "}


/* end https://en.wikipedia.org/ */
</style><style data-mw-deduplicate="TemplateStyles:r1236075235">
/* start https://en.wikipedia.org/ */


.mw-parser-output .navbox{box-sizing:border-box;border:1px solid #a2a9b1;width:100%;clear:both;font-size:88%;text-align:center;padding:1px;margin:1em auto 0}.mw-parser-output .navbox .navbox{margin-top:0}.mw-parser-output .navbox+.navbox,.mw-parser-output .navbox+.navbox-styles+.navbox{margin-top:-1px}.mw-parser-output .navbox-inner,.mw-parser-output .navbox-subgroup{width:100%}.mw-parser-output .navbox-group,.mw-parser-output .navbox-title,.mw-parser-output .navbox-abovebelow{padding:0.25em 1em;line-height:1.5em;text-align:center}.mw-parser-output .navbox-group{white-space:nowrap;text-align:right}.mw-parser-output .navbox,.mw-parser-output .navbox-subgroup{background-color:#fdfdfd}.mw-parser-output .navbox-list{line-height:1.5em;border-color:#fdfdfd}.mw-parser-output .navbox-list-with-group{text-align:left;border-left-width:2px;border-left-style:solid}.mw-parser-output tr+tr>.navbox-abovebelow,.mw-parser-output tr+tr>.navbox-group,.mw-parser-output tr+tr>.navbox-image,.mw-parser-output tr+tr>.navbox-list{border-top:2px solid #fdfdfd}.mw-parser-output .navbox-title{background-color:#ccf}.mw-parser-output .navbox-abovebelow,.mw-parser-output .navbox-group,.mw-parser-output .navbox-subgroup .navbox-title{background-color:#ddf}.mw-parser-output .navbox-subgroup .navbox-group,.mw-parser-output .navbox-subgroup .navbox-abovebelow{background-color:#e6e6ff}.mw-parser-output .navbox-even{background-color:#f7f7f7}.mw-parser-output .navbox-odd{background-color:transparent}.mw-parser-output .navbox .hlist td dl,.mw-parser-output .navbox .hlist td ol,.mw-parser-output .navbox .hlist td ul,.mw-parser-output .navbox td.hlist dl,.mw-parser-output .navbox td.hlist ol,.mw-parser-output .navbox td.hlist ul{padding:0.125em 0}.mw-parser-output .navbox .navbar{display:block;font-size:100%}.mw-parser-output .navbox-title .navbar{float:left;text-align:left;margin-right:0.5em}body.skin--responsive .mw-parser-output .navbox-image img{max-width:none!important}@media print{body.ns-0 .mw-parser-output .navbox{display:none!important}}


/* end https://en.wikipedia.org/ */
</style></div><div role="navigation" class="navbox" aria-labelledby="Compiler_optimizations253" style="padding:3px"><table class="nowraplinks mw-collapsible autocollapse navbox-inner" style="border-spacing:0;background:transparent;color:inherit"><tbody><tr><th scope="col" class="navbox-title" colspan="2"><style data-mw-deduplicate="TemplateStyles:r1239400231">
/* start https://en.wikipedia.org/ */


.mw-parser-output .navbar{display:inline;font-size:88%;font-weight:normal}.mw-parser-output .navbar-collapse{float:left;text-align:left}.mw-parser-output .navbar-boxtext{word-spacing:0}.mw-parser-output .navbar ul{display:inline-block;white-space:nowrap;line-height:inherit}.mw-parser-output .navbar-brackets::before{margin-right:-0.125em;content:"[ "}.mw-parser-output .navbar-brackets::after{margin-left:-0.125em;content:" ]"}.mw-parser-output .navbar li{word-spacing:-0.125em}.mw-parser-output .navbar a>span,.mw-parser-output .navbar a>abbr{text-decoration:inherit}.mw-parser-output .navbar-mini abbr{font-variant:small-caps;border-bottom:none;text-decoration:none;cursor:inherit}.mw-parser-output .navbar-ct-full{font-size:114%;margin:0 7em}.mw-parser-output .navbar-ct-mini{font-size:114%;margin:0 4em}html.skin-theme-clientpref-night .mw-parser-output .navbar li a abbr{color:var(--color-base)!important}@media(prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .navbar li a abbr{color:var(--color-base)!important}}@media print{.mw-parser-output .navbar{display:none!important}}


/* end https://en.wikipedia.org/ */
</style><div id="Compiler_optimizations253" style="font-size:114%;margin:0 4em"><a href="Optimizing_compiler" title="Optimizing compiler">Compiler optimizations</a></div></th></tr><tr><th scope="row" class="navbox-group" style="width:1%">Basic block</th><td class="navbox-list-with-group navbox-list navbox-odd hlist" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Peephole_optimization" title="Peephole optimization">Peephole optimization</a></li>
<li><a href="Local_value_numbering" class="mw-redirect" title="Local value numbering">Local value numbering</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Loop_optimization" title="Loop optimization">Loop</a></th><td class="navbox-list-with-group navbox-list navbox-even hlist" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Automatic_parallelization" title="Automatic parallelization">Automatic parallelization</a></li>
<li><a href="Automatic_vectorization" title="Automatic vectorization">Automatic vectorization</a></li>
<li><a href="Induction_variable" title="Induction variable">Induction variable</a></li>
<li><a href="Loop_fusion" class="mw-redirect" title="Loop fusion">Loop fusion</a></li>
<li><a href="Loop-invariant_code_motion" title="Loop-invariant code motion">Loop-invariant code motion</a></li>
<li><a href="Loop_inversion" title="Loop inversion">Loop inversion</a></li>
<li><a href="Loop_interchange" title="Loop interchange">Loop interchange</a></li>
<li><a href="Loop_nest_optimization" title="Loop nest optimization">Loop nest optimization</a></li>
<li><a href="Loop_splitting" title="Loop splitting">Loop splitting</a></li>
<li><a href="Loop_unrolling" title="Loop unrolling">Loop unrolling</a></li>
<li><a href="Loop_unswitching" title="Loop unswitching">Loop unswitching</a></li>
<li><a href="Software_pipelining" title="Software pipelining">Software pipelining</a></li>
<li><a href="Strength_reduction" title="Strength reduction">Strength reduction</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Data-flow_analysis" title="Data-flow analysis">Data-flow<br>analysis</a></th><td class="navbox-list-with-group navbox-list navbox-odd hlist" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Available_expression" title="Available expression">Available expression</a></li>
<li><a href="Common_subexpression_elimination" title="Common subexpression elimination">Common subexpression elimination</a></li>
<li><a href="Constant_folding" title="Constant folding">Constant folding</a></li>
<li><a href="Dead_store" title="Dead store">Dead store</a> elimination</li>
<li><a href="Induction_variable_recognition_and_elimination" class="mw-redirect" title="Induction variable recognition and elimination">Induction variable recognition and elimination</a></li>
<li><a href="Live-variable_analysis" title="Live-variable analysis">Live-variable analysis</a></li>
<li><a href="Upwards_exposed_uses" title="Upwards exposed uses">Upwards exposed uses</a></li>
<li><a href="Use-define_chain" title="Use-define chain">Use-define chain</a></li>
<li><a href="Reaching_definition" title="Reaching definition">Reaching definitions</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Static_single-assignment_form" title="Static single-assignment form">SSA</a>-based</th><td class="navbox-list-with-group navbox-list navbox-even hlist" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Global_value_numbering" class="mw-redirect" title="Global value numbering">Global value numbering</a></li>
<li><a href="Sparse_conditional_constant_propagation" title="Sparse conditional constant propagation">Sparse conditional constant propagation</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Code_generation_(compiler)" title="Code generation (compiler)">Code generation</a></th><td class="navbox-list-with-group navbox-list navbox-odd hlist" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Instruction_scheduling" title="Instruction scheduling">Instruction scheduling</a></li>
<li><a href="Instruction_selection" title="Instruction selection">Instruction selection</a></li>
<li><a href="Register_allocation" title="Register allocation">Register allocation</a></li>
<li><a href="Rematerialization" title="Rematerialization">Rematerialization</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%">Functional</th><td class="navbox-list-with-group navbox-list navbox-even hlist" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Deforestation_(computer_science)" title="Deforestation (computer science)">Deforestation</a></li>
<li><a href="Tail_call" title="Tail call">Tail-call elimination</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%">Global</th><td class="navbox-list-with-group navbox-list navbox-odd hlist" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Interprocedural_optimization" title="Interprocedural optimization">Interprocedural optimization</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%">Other</th><td class="navbox-list-with-group navbox-list navbox-even hlist" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Bounds-checking_elimination" title="Bounds-checking elimination">Bounds-checking elimination</a></li>
<li><a href="Compile-time_function_execution" title="Compile-time function execution">Compile-time function execution</a></li>
<li><a href="Dead-code_elimination" title="Dead-code elimination">Dead-code elimination</a></li>
<li><a href="Expression_templates" title="Expression templates">Expression templates</a></li>
<li><a href="Inline_expansion" title="Inline expansion">Inline expansion</a></li>
<li><a href="Jump_threading" title="Jump threading">Jump threading</a></li>
<li><a href="Partial_evaluation" title="Partial evaluation">Partial evaluation</a></li>
<li><a href="Profile-guided_optimization" title="Profile-guided optimization">Profile-guided optimization</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%">Static analysis</th><td class="navbox-list-with-group navbox-list navbox-odd hlist" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Alias_analysis" title="Alias analysis">Alias analysis</a></li>
<li><a href="Array-access_analysis" title="Array-access analysis">Array-access analysis</a></li>
<li><a href="Control-flow_analysis" title="Control-flow analysis">Control-flow analysis</a></li>
<li><a href="Data-flow_analysis" title="Data-flow analysis">Data-flow analysis</a></li>
<li><a href="Dependence_analysis" title="Dependence analysis">Dependence analysis</a></li>
<li><a href="Escape_analysis" title="Escape analysis">Escape analysis</a></li>
<li><a href="Pointer_analysis" title="Pointer analysis">Pointer analysis</a></li>
<li><a href="Shape_analysis_(program_analysis)" title="Shape analysis (program analysis)">Shape analysis</a></li>
<li><a href="Value_range_analysis" title="Value range analysis">Value range analysis</a></li></ul>
</div></td></tr></tbody></table></div></div><!--htdig_noindex--><div><div class="zim-footer">
This article is issued from <a class="external text" title="Last edited on 2025-07-13" href="https://en.wikipedia.org/wiki/?title=Program_optimization&amp;oldid=1300239431">Wikipedia</a>. The text is available under <a class="external text" href="https://creativecommons.org/licenses/by-sa/4.0/deed.en">Creative Commons Attribution-Share Alike 4.0</a> unless otherwise noted. Additional terms may apply for the media files.
</div>
</div><!--/htdig_noindex--></div>
</div>
</main>
</div>
</div>
</div>

</body></html>